# -*- coding:utf-8 -*-
'''
Created on 2010-9-28

@author: lijun
'''

import httplib, urllib, urllib2,cookielib


def TestUseInfoAPI():
    host = '10.20.128.129'
    conn = httplib.HTTPConnection(host)
    
    useinfoXml = '''
            <useinfo>
            <time>2010-09-23 22:22:22</time>
            <user>lijun-test</user>
            <action>addNote</action>
            <code>OK</code>
            </useinfo> 
    '''
    headers = {"Content-type": "application/x-www-form-urlencoded",
            "Accept": "text/html"}  
#    
    params = urllib.urlencode({'useinfo': useinfoXml})
    
    
    conn.request("POST", "/kspider/info/", params, headers)
    response = conn.getresponse()
    print response.status, response.reason
    data = response.read()
    print data
    
    fileInfoXml = '''
    <fileinfo>
    <time>2010-09-23 10:02:20</time>
    <user>lijun-test</user>
    <filesize>202934</filesize>
    <filecount>105</filecount>
    </fileinfo>
    '''
    
    params = urllib.urlencode({'fileinfo': fileInfoXml})
    conn.request("POST", "/kspider/info/", params, headers)
    response = conn.getresponse()
    print response.status, response.reason
    data = response.read()
    print data
    
    conn.close()
    
    
if __name__ == '__main__':
    TestUseInfoAPI()


